/*******************************************************************************
 * Copyright (c) 2004, 2005 Elias Volanakis and others.
�* All rights reserved. This program and the accompanying materials
�* are made available under the terms of the Eclipse Public License v1.0
�* which accompanies this distribution, and is available at
�* http://www.eclipse.org/legal/epl-v10.html
�*
�* Contributors:
�*����Elias Volanakis - initial API and implementation
�*******************************************************************************/
package org.eclipse.gef.examples.shapes.model;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

import com.minotauro.workflow.xml.netpetri.DefaultDocSectionState;
import com.minotauro.workflow.xml.netpetri.DocSectionState;
import com.minotauro.workflow.xml.netpetri.MetaData;

/**
 * A rectangular shape.
 * @author Elias Volanakis
 */
public class TransitionShape extends Shape {

  /** A 16x16 pictogram of a rectangular shape. */
  private static final String TRANS_NAME_PROP = "Name";
  private static final Image RECTANGLE_ICON = createImage("icons/rectangle16.gif");
  private DefaultDocSectionState defaultDocSectionState;
  private List<DocSectionState> docSectionState;
  //  private List<PrePlace> prePlace;
  //  private List<PosPlace> posPlace;

  private static final long serialVersionUID = 1;

  private String Name = new String();

  static {

    descriptors = new IPropertyDescriptor[]{new TextPropertyDescriptor(TRANS_NAME_PROP, "Name")};
  } // static

  public TransitionShape() {
    // Empty
  }

  public TransitionShape(List<MetaData> metaData, DefaultDocSectionState defaultDocSectionState,
      List<DocSectionState> docSectionState, String name) {
    super();
    this.metaData = metaData;
    this.defaultDocSectionState = defaultDocSectionState;
    this.docSectionState = docSectionState;
    Name = name;
  }

  public IPropertyDescriptor[] getPropertyDescriptors() {
    return descriptors;
  }

  public Object getPropertyValue(Object propertyId) {
    if (TRANS_NAME_PROP.equals(propertyId)) {
      return Name;
    }
    return super.getPropertyValue(propertyId);
  }

  public void setPropertyValue(Object propertyId, Object value) {

    if (TRANS_NAME_PROP.equals(propertyId)) {
      setName((String) value);
    } else {
      super.setPropertyValue(propertyId, value);
    }
  }

  public Image getIcon() {
    return RECTANGLE_ICON;
  }

  public String toString() {
    return "Rectangle " + hashCode();
  }

  public void setName(String name) {
    Name = name;
  }

  public String getName() {
    return Name;
  }

  public void setDefaultDocSectionState(DefaultDocSectionState defaultDocSectionState) {
    this.defaultDocSectionState = defaultDocSectionState;
  }

  public DefaultDocSectionState getDefaultDocSectionState() {
    return defaultDocSectionState;
  }

  public void setDocSectionState(List<DocSectionState> docSectionState) {
    this.docSectionState = docSectionState;
  }

  public List<DocSectionState> getDocSectionState() {
    if (docSectionState == null) {
      docSectionState = new ArrayList<DocSectionState>();
    }
    return this.docSectionState;
  }

  public long getSerialVersionUID() {
    return serialVersionUID;
  }

}
